<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
        <link rel="stylesheet" href="elementUI/theme-default/index.css" /> 
    </head>
    <body>
        <script src="js/vue.js"></script>
        <script src="elementUI/index.js"></script>
        <div id="app">
          <el-autocomplete
            v-model="manager"
            :fetch-suggestions="querySearchAsync"
            placeholder="请输入内容" 
            @select="handleSelect">
          </el-autocomplete>
        </div>
        <script>
          new Vue({
            el:'#app',
            data() {
              return {
                managers: [],
                manager: '',
                timeout:  null
              };
            },
            methods: {
              loadAll() {
                return [
                {
                    "roomkey": "",
                    "roomid": 0,
                    "id": 1,
                    "status": 1,
                    "accid": '100799621',
                    "app_id": "dftv",
                    "info": 1
                },{
                    "roomkey": "",
                    "roomid": 0,
                    "id": 1,
                    "status": 1,
                    "accid": '110799621',
                    "app_id": "dftv",
                    "info": 1
                },{
                    "roomkey": "",
                    "roomid": 0,
                    "id": 1,
                    "status": 1,
                    "accid": '110799621',
                    "app_id": "dftv",
                    "info": 1
                }
                  // { "value": '120', "address": "长宁区新渔路144号" }
                  // { "value": 110, "address": "上海市长宁区淞虹路661号" },
                  // { "value": 220, "address": "上海市普陀区真北路988号创邑金沙谷6号楼113" },
                  // { "value": 210, "address": "天山西路438号" }
                ];
              },
              querySearchAsync(queryString, cb) {
                var managers = this.managers;
                var results = queryString ? managers.filter(this.createStateFilter(queryString)) : managers;

                clearTimeout(this.timeout);
                this.timeout = setTimeout(() => {
                  cb(results);
                }, 3000 * Math.random());
              },
              createStateFilter(queryString) {
                return (state) => {
                  return (state.accid.indexOf(queryString.toLowerCase()) === 0);
                };
              },
              handleSelect(item) {
                console.log('item',item);
              }
            },
            mounted() {
              this.managers = this.loadAll();
            }
          });
        </script>
    </body>
</html>